﻿#include "searchentry.h"

#include <QIcon>
#include <QShortcut>

SearchEntry::SearchEntry(QWidget *parent)
    : QLineEdit(parent)
    , m_btnSearch(new QPushButton(this))
{
    this->setMaxLength(5);
    this->setPlaceholderText("输入关键字");

    QIcon icon(":/new/prefix1/搜索.png");
    m_btnSearch->setIcon(icon);
    m_btnSearch->setFocusPolicy(Qt::NoFocus);
    m_btnSearch->setCursor(Qt::ArrowCursor);
    // 设置快捷键
    m_btnSearch->setShortcut(Qt::Key_Return);
    m_btnSearch->setStyleSheet("QPushButton { border-radius: 0px; }");

    connect(m_btnSearch, &QPushButton::clicked, this, &SearchEntry::onBtnClicked);

    // 设置布局
    auto hlay = new QHBoxLayout(this);
    hlay->addStretch();
    hlay->addWidget(m_btnSearch);
    hlay->setAlignment(Qt::AlignRight);
    hlay->setContentsMargins(0, 0, 0, 0);
}



